layui.use(['jquery','layer'],function(){
   'use strict';
	var $ = layui.jquery
	   ,layer=layui.layer;
	
	$(window).on('resize',function(){
		var w = $(window).width();
		var h = $(window).height();
		$('.larry-canvas').width(w).height(h);
	}).resize();
	
	//登录链接测试，使用时可删除
	$(".submit_btn").click(function(){
		login();
	});
	$(function(){
		$("#canvas").jParticle({
			background: "#23262E",
			color: "#E5E5E5"
		});
	});
});

var loginSubmit = false;
function login() {
	if (loginSubmit) {
		return;
	}
	if ($("#userCode").val() == "") {
		$("#mssage").html("用户名不能为空");
		return false;
	}
	if ($("#password").val() == "") {
		$("#mssage").html("密码不能为空");
		return false;
	}
	loginSubmit = true;
	var load = layer.load(0, {shade: false});
	$.post("loginController/login.html",
		{userCode: $("#userCode").val(), password: $("#password").val(), checkcode: $("#checkcode").val()},
		function (data) {
			layer.close(load);
			loginSubmit = false;
			if (data.result && data.msg == "ok") {
				window.location.href = "index.jsp";
			} else {
				alert(data.msg);
			}
		}, "json");
}
function enterLogin() {
	if ($("#userCode").val() == "") {
		$("#userCode").focus();
		return false;
	}
	if ($("#password").val() == "") {
		$("#password").focus();
		return false;
	}
	login();
}